import math
import operator
from functools import reduce

class Solution(object):
    def integerBreak(self, n):
        """
        :type n: int
        :rtype: int
        """
        if n == 2:
            return 1
        elif n == 3:
            return 2

        nPieces = math.sqrt(n)
        nPieces = math.floor(nPieces)
        nPieces = int(nPieces)

        maxResult = 0

        while True:
            factors = [n // nPieces] * nPieces
            tail = n % nPieces
            for i in range(tail):
                factors[i] = factors[i] + 1
            result = reduce(operator.mul, factors, 1)
            if result > maxResult:
                maxResult = result
                nPieces = nPieces + 1
            else:
                break
        return maxResult

s = Solution()
print(s.integerBreak(14))